/*
 * File: DelayTimesSe.c
 *
 * Code generated for Simulink model 'FLTM'.
 *
 * Model version                  : 3.512
 * Simulink Coder version         : 9.4 (R2020b) 29-Jul-2020
 * C/C++ source code generated on : Tue Apr 26 13:54:46 2022
 */

#include "DelayTimesSe.h"

/*
 * Output and update for atomic system:
 *    'DelayTimesforS' ('mylib:24')
 *    'DelayTimesforS' ('mylib:24')
 *    'DelayTimesforS' ('mylib:24')
 *    'DelayTimesforS' ('mylib:24')
 *    'DelayTimesforS' ('mylib:24')
 *    'DelayTimesforS' ('mylib:24')
 *    'DelayTimesforS' ('mylib:24')
 *    'DelayTimesforS' ('mylib:24')
 *    'DelayTimesforS' ('mylib:24')
 *    'DelayTimesforS' ('mylib:24')
 *    ...
 */
void DelayTimesSe(boolean_T T_F, B_DelayTimesSe_T *localB, DW_DelayTimesSe_T
                  *localDW, uint16_T rtp_time)
{
    int32_T tmp;
    uint16_T T_F_0;
    if (T_F)
    {
        T_F_0 = 0U;
    }
    else
    {
        T_F_0 = localDW->UnitDelay1_DSTATE;
    }

    tmp = (localDW->UnitDelay3_DSTATE + T_F) - T_F_0;
    if (tmp < 0)
    {
        tmp = 0;
    }
    else
    {
        if (tmp > 65535)
        {
            tmp = 65535;
        }
    }

    localB->Compare_ih = ((uint16_T)tmp >= rtp_time);
    localDW->UnitDelay3_DSTATE = (uint16_T)tmp;
    localDW->UnitDelay1_DSTATE = (uint16_T)tmp;
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
